<template>
    <div class="reporting">
        <header class="header">
            <x-header class="headerContent" :left-options="{backText: ''}"><span class="title">在线缴费</span><a slot="right" class="slotRight" @click="record">缴费记录</a></x-header>
        </header>
        <main class="main" v-if="fullShow">
            <p class="tipTitle">请您确认账单</p>
            <ul class="list">
                <li class="listItem" v-for="(item, index) in datalist" :key="index" @click="payDetail(item, index)">
                    <div class="parent_list">
                        <div class="inps" v-show="choiceShow" ref="show"><span>√</span></div>
                        <div class="inp" v-show="choiceHide" ref="hide"><span>√</span></div>
                        <div class="left">
                            <p class="name_title">{{item.title}}</p>
                            <p class="name_date">{{item.date}}</p>
                        </div>
                    </div>
                    <div class="right">
                        <p class="name_explain">{{item.money}}</p>
                    </div>
                </li>
            </ul>
        </main>
        <main class="main" v-else>
            <div class="contentNull">
                <span>没有即将要缴费的单子</span>
            </div>
        </main>
        <footer class="footer" @click="submission">确认缴费</footer>
    </div>
</template>
<script>
import { XHeader } from 'vux'
import API from '../../config/api_user.js'
import Qs from 'qs'
export default {
    name: 'Paydetail',
    data () {
        return {
            datalist: [],
            choiceShow: false,
            choiceHide: true,
            fullShow: null,
            count: [],
            item: {},
            ind: []
        }
    },
    components: {
        XHeader
    },
    created () {
        let userid = JSON.parse(sessionStorage.getItem('userInfo')).page.userid
        let params ={
            userid: userid
        }
        API.paymentList(params).then(res => {
            if (res.page.length == 0) {
                this.fullShow = false
            } else {
                res.page.map((item, index) => {
                    if (item.payment_state == '未缴费') {
                        this.fullShow = true
                        this.datalist.push(item)
                    }
                })
                var t = new Array(this.datalist.length);
                this.count = t;
            }
        })
    },
    methods: {
        goDetail (item) {
            switch(item) {
                case 'electronics': 
                    this.$router.push({ path: '/Home/Reporting/Electronics' })
                break;
                case 'page':
                    this.$router.push({ path: '/Home/Reporting/Page' })
                break;
            }
        },
        submission () {
            // alert('调支付接口')
            if (this.ind.length>=1) {
                console.log(this.item)
            } else {
                alert('请选择缴费账单')
            }
        },
        record () {
            this.$router.push({
                path: '/Home/Paymentrecord'
            })
        },
        payDetail (item, index) {
            this.ind.push(index)
            this.count[index]?this.count[index]=this.count[index]:this.count[index]=1;
            if (this.count[index] == 1) {
                this.$refs.show[index].style.display = 'block'
                this.$refs.hide[index].style.display = 'none'
                this.$refs.show[index].style.background = 'rgba(255,199,38,1)'
                this.count[index]++
            } else if(this.count[index] == 2) {
                this.$refs.show[index].style.display = 'none'
                this.$refs.hide[index].style.display = 'block'
                this.count[index] = 1
            }
            this.item = item
        }
    }
}
</script>
<style scoped lang="less">
.reporting{
    width: 100%;
    height: 100%;
    background: rgba(250, 250, 250, 1);
}
.header{
    width: 100%;
}
.title{
    font-size: 16px;
    font-family:ArialMT;
    color:rgba(255,255,255,1);
    letter-spacing:1px;
}
.headerContent{
    width: 100%;
    background:linear-gradient(135deg,rgba(255,199,38,1) 0%,rgba(249,151,22,1) 100%);
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
}
.main{
    width: 100%;
    .tipTitle{
        width: 100%;
        height: .96rem;
        padding: .213333rem .133333rem;
        background: rgba(250, 250, 250, 1);
        display: flex;
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
        font-size:14px;
        font-family:ArialMT;
        color:rgba(249,152,23,1);
        letter-spacing:1px;
    }
    .list{
        width: 100%;
        .listItem{
            width: 100%;
            height: 1.946667rem;
            background: #fff;
            padding: 0 .48rem;
            position: relative;
            display: flex;
            flex-direction: row;
            justify-content: space-between;
            align-items: center;
            position: relative;
            .parent_list{
                width: 6.666667rem;
                height: 100%;
                display: flex;
                flex-direction: row;
                justify-content: flex-start;
                align-items: center;
                .inp{
                    width: .466667rem;
                    height: .466667rem;
                    border-radius: 100%;
                    margin-right: .4rem;
                    color: #fff;
                    text-align: center;
                    span{
                        display: block;
                        width: 100%;
                        height: 100%;
                        border: 1px solid rgba(255,199,38,1);
                        border-radius: 100%;
                        display: flex;
                        flex-direction: row;
                        justify-content: center;
                        align-items: center;
                    }
                }
                .inps{
                    width: .466667rem;
                    height: .466667rem;
                    border-radius: 100%;
                    margin-right: .4rem;
                    color: #fff;
                    text-align: center;
                    line-height: 0.2rem;
                    span{
                        display: block;
                        width: 100%;
                        height: 100%;
                        border: 1px solid rgba(255,199,38,1);
                        border-radius: 100%;
                        background:rgba(255,199,38,1);
                        display: flex;
                        flex-direction: row;
                        justify-content: center;
                        align-items: center;
                    }
                }
                .left{
                    width: 6rem;
                    height: 100%;
                    display: flex;
                    flex-direction: column;
                    justify-content: center;
                    align-items: center;
                    .name_title{
                        width: 100%;
                        height: .7rem;
                        display: flex;
                        flex-direction: row;
                        justify-content: flex-start;
                        align-items: center;
                        font-size:14px;
                        font-family:ArialMT;
                        color:rgba(82,82,82,1);
                        letter-spacing:1px;
                    }
                    .name_date {
                        width: 100%;
                        height: .7rem;
                        display: flex;
                        flex-direction: row;
                        justify-content: flex-start;
                        align-items: center;
                        font-size:12px;
                        font-family:ArialMT;
                        color:rgba(204,204,204,1);
                        letter-spacing:1px;
                    }
                }
            }
            .right{
                width: 2rem;
                height: 100%;
                display: flex;
                flex-direction: row;
                justify-content: center;
                align-items: center;
                .name_explain{
                    width: 100%;
                    height: 100%;
                    display: flex;
                    flex-direction: row;
                    justify-content: flex-end;
                    align-items: center;
                    font-size:12px;
                    font-family:ArialMT;
                    color:rgba(82,82,82,1);
                    letter-spacing:1px;
                }
            }
        }
        .listItem:after{
            content: '';
            position: absolute;
            left: 0;
            bottom: 0;
            background: #cccccc;
            width: 100%;
            height: 1px;
            -webkit-transform: scaleY(0.5);
            transform: scaleY(0.5);
            -webkit-transform-origin: 0 0;
            transform-origin: 0 0;
        }
    }
    .contentNull{
        width: 100%;
        height: 1.333333rem;
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        span{
            font-size: 16px;
            font-family:ArialMT;
            letter-spacing:1px;
        }
    }
}
.footer{
    position: fixed;
    bottom: 0;
    width: 100%;
    height: 1.28rem;
    font-size: 0.16rem;
    font-size:16px;
    font-family:PingFangSC-Regular;
    font-weight:400;
    color:rgba(255,255,255,1);
    letter-spacing:1px;
    color: #fff;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    background:linear-gradient(118deg,rgba(255,199,38,1) 0%,rgba(249,151,22,1) 100%);
}
.slotRight{
    color: #fff !important;
    margin-top: .266667rem;
    font-size:12px;
    font-family:ArialMT;
    letter-spacing:1px;
    line-height:14px;
}
</style>
